package com.ece;

import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.ObjectMessage;

import com.ece.beans.Commande;

/**
 * Message-Driven Bean implementation class for: LivraisonMDB
 *
 */
@MessageDriven(activationConfig =
{ @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
		@ActivationConfigProperty(propertyName="destination", propertyValue="queue/MyTestQueue"),
})
public class LivraisonMDB implements MessageListener {

    /**
     * Default constructor. 
     */
    public LivraisonMDB() {
    }
	
	/**
     * @see MessageListener#onMessage(Message)
     */
    public void onMessage(Message message) {
		try {
//			TextMessage tm = (TextMessage)message;
//			String text = tm.getText();
			ObjectMessage om = (ObjectMessage)message;
			Commande commande = (Commande)om.getObject();
			System.out.println(commande.toString());
		} catch(Exception e) {
			e.printStackTrace();
		}
	}

}
